/**
 * @Author: dn-jinmin
 * @File:  main
 * @Version: 1.0.0
 * @Date: 2024/3/18
 * @Description:
 */

package main

import (
	"context"
	"gitee.com/dn-jinmin/tlog"
	"go.uber.org/zap"
)

type zapWriter struct {
	*zap.Logger
}

func NewZapWriter() *zapWriter {
	l, _ := zap.NewProduction()
	return &zapWriter{Logger: l}
}

func (z *zapWriter) Write(ctx context.Context, content *tlog.Content, fields ...tlog.Field) {
	switch content.Level {
	case tlog.INFO:
		z.Logger.Info(content.Msg,
			zap.String("traceId", content.TraceId),
			zap.String("relatedId", content.RelatedId),
			zap.String("level", content.Level),
			zap.String("path", content.Path),
			zap.String("label", content.Label),
		)
	}
}
